﻿package mortal.game.view.petNew.view
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import com.gengine.resource.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.model.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.tooltip.*;
    import mortal.game.view.guide.*;
    import mortal.game.view.mount.data.*;
    import mortal.game.view.shop.*;
    import mortal.game.view.signUp.sevenDayLogin.data.*;
    import mortal.mvc.core.*;

    public class PetInfoRightInfoView extends GSprite
    {
        private var _name:GTextFiled;
        private var _level:GImageBitmap;
        private var _advanceInfo:GTextFiled;
        protected var _currLevel:BitmapNumberText;
        protected var _nextLevel:BitmapNumberText;
        protected var _curBg:GImageBitmap;
        protected var _nextBg:GImageBitmap;
        protected var _arrow:GImageBitmap;
        protected var _fullLevel:GTextFiled;
        private var _myselfHurt:BitmapNumberText;
        private var _addRoleHutr:BitmapNumberText;
        private var _progressBar:BaseProgressBar;
        private var _commonAdvanceBtn:GLoadingButton;
        private var _autoAdvanceBtn:GLoadingButton;
        private var _stopAdvanceBtn:GLoadingButton;
        private var _servenActivitiesBtn:GLoadingButton;
        private var _consumeItem:BaseItem;
        private var _propNum:GTextFiled;
        private var _propName:GTextFiled;
        private var _propTip:GTextFiled;
        private var _autoBuy:GCheckBox;
        private var _addCombat:GTextFiled;
        private var _addCombatIcon:GBitmap;
        private var _vcAttributeName:Vector.<String>;
        private var _vcAttributeNameText:Vector.<GTextFiled>;
        private var _vcAttributeValueText:Vector.<BitmapNumberText>;
        private var _vcAttributeAddValueText:Vector.<GTextFiled>;
        private var _upgradeArrowArr:Vector.<GBitmap>;
        private var _promoteSp:Sprite;
        private var _overFun:Function;
        private var _outFun:Function;
        private var _pet:SPublicPet2;
        private var _isAutoingRefresh:Boolean;
        private var _hasCkAutoBtn:Boolean;
        protected var _window:Window;
        private var _roundArrCode:int = 410540001;
        private var _timeoutNum:int;

        public function PetInfoRightInfoView(param1:Window)
        {
            this._vcAttributeName = new Vector.<String>;
            this._vcAttributeNameText = new Vector.<GTextFiled>;
            this._vcAttributeValueText = new Vector.<BitmapNumberText>;
            this._vcAttributeAddValueText = new Vector.<GTextFiled>;
            this._upgradeArrowArr = new Vector.<GBitmap>;
            this._window = param1;
            return;
        }// end function

        private function onRecCompl() : void
        {
            pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.PetInfoTxt2, 64, 45, this));
            pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.PetInfoTxt3, 65, 128, this));
            pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.PetInfoTxt5, 94, 322, this));
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_2:GTextFiled = null;
            var _loc_3:BitmapNumberText = null;
            var _loc_4:GBitmap = null;
            var _loc_5:GTextFormat = null;
            super.createDisposedChildrenImpl();
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.AdvanceInfoBg, 0, 0, this));
            this._level = UIFactory.gImageBitmap("", 64, 2, this);
            this._name = UIFactory.gTextField("", 130, 3, 260, 35, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(16).setBold(true));
            this._advanceInfo = UIFactory.gTextField("", 0, 371, 262, 20, this, GlobalStyle.textFormatLv.center().setSize(13));
            this._myselfHurt = UIFactory.bitmapNumberText(-191, 37, "GuildCopyNum.png", 24, 32, -6, this, 9, BitmapNumberText.Mid);
            this._addRoleHutr = UIFactory.bitmapNumberText(127, 72, "WizardCombatNum.png", 23, 30, -3, this, 13, BitmapNumberText.Mid);
            this._progressBar = UICompomentPool.getUICompoment(BaseProgressBar);
            this._progressBar.setBg(ImagesConst.MountBarBg, true, 246, 13);
            this._progressBar.setProgress(ImagesConst.MountBar, true, 4, 4, 238, 13);
            this._progressBar.setLabel(BaseProgressBar.ProgressBarTextOnlyShowValue, 25);
            this._progressBar.toolTipData = this.getPetBlessToolTip;
            this._progressBar.mouseEnabled = true;
            this._progressBar.isOverShowValue = true;
            UIFactory.setObjAttri(this._progressBar, 8, 395, -1, -1, this);
            this._consumeItem = UIFactory.baseItem(134, 425, 28, 28, this);
            this._consumeItem.setItemStyle();
            this._propNum = UIFactory.gTextField("", 182, 436, 37, 20, this);
            this._propName = UIFactory.gTextField("", 58, 443, 80, 20, this, GlobalStyle.textFormatZi);
            this._autoBuy = UIFactory.checkBox("" + Language.getString(71760), 59, 516, 140, 28, this);
            this._propTip = UIFactory.gTextField("" + Language.getString(71761), 64, 425, 55, 20, this);
            this._curBg = UIFactory.gImageBitmap(ImagesConst.SystemAdvanceBg, 55, 350, this);
            this._nextBg = UIFactory.gImageBitmap(ImagesConst.SystemAdvanceBg, 150, 350, this);
            this._arrow = UIFactory.gImageBitmap(ImagesConst.SystemAdvanceArrow, 103, 357, this);
            this._currLevel = UIFactory.bitmapNumberText(76, 357, "GuildNewBuildingNum2.png", 21, 24, -10, this, 13, 1);
            this._nextLevel = UIFactory.bitmapNumberText(171, 357, "GuildNewBuildingNum2.png", 21, 24, -10, this, 13, 1);
            this._fullLevel = UIFactory.gTextField("" + Language.getString(71762), 29, 358, 200, 25, this, GlobalStyle.textFormatAnHuan.setSize(14).center().setBold(true));
            this._fullLevel.multiline = true;
            this._fullLevel.wordWrap = true;
            this._fullLevel.visible = false;
            this._commonAdvanceBtn = UIFactory.gLoadingButton(ResFileConst.SystemAdvanceBtn, 18, 474, 114, 33, this);
            this._commonAdvanceBtn.name = "PetGrowing_upgradeBtn";
            this._commonAdvanceBtn.drawNow();
            this._autoAdvanceBtn = UIFactory.gLoadingButton(ResFileConst.SystemAutoAdvanceBtn, 129, 474, 114, 33, this);
            this._autoAdvanceBtn.drawNow();
            this._stopAdvanceBtn = UIFactory.gLoadingButton(ResFileConst.CancelAdvanceBtn, 130, 474, 114, 33, this);
            this._stopAdvanceBtn.drawNow();
            this._stopAdvanceBtn.visible = false;
            this._promoteSp = UIFactory.sprite(0, 0, this);
            this._promoteSp.visible = false;
            var _loc_1:* = GlobalStyle.textFormatItemGreen.left();
            _loc_1.size = 16;
            this._addCombat = UIFactory.gTextField("", 200, 70, 60, 25, this._promoteSp, _loc_1);
            this._addCombatIcon = UIFactory.gBitmap(ImagesConst.ascendingSortBtn_upSkin, 190, 76, this._promoteSp);
            this._vcAttributeName = MountConfig.instance.attribute.concat();
            var _loc_6:int = 0;
            while (_loc_6 < this._vcAttributeName.length)
            {
                
                _loc_3 = UIFactory.bitmapNumberText(55 + _loc_6 % 2 * 134, 12 * (_loc_6 - _loc_6 % 2) + 164, "RoleInfoNum.png", 8, 10, -1, this, 14);
                this._vcAttributeValueText.push(_loc_3);
                pushUIToDisposeVec(_loc_3);
                _loc_2 = UIFactory.gTextField("", 102 + _loc_6 % 2 * 124, 12 * (_loc_6 - _loc_6 % 2) + 157, 60, 20, this._promoteSp, GlobalStyle.textFormatItemGreen);
                this._vcAttributeAddValueText.push(_loc_2);
                pushUIToDisposeVec(_loc_2);
                _loc_4 = UIFactory.gBitmap(ImagesConst.upgradeArrow, 92 + _loc_6 % 2 * 124, 12 * (_loc_6 - _loc_6 % 2) + 161, this._promoteSp);
                _loc_4.visible = false;
                this._upgradeArrowArr.push(_loc_4);
                pushUIToDisposeVec(_loc_4);
                _loc_6++;
            }
            this._commonAdvanceBtn.configEventListener(MouseEvent.CLICK, this.onClickUpgrade);
            this._commonAdvanceBtn.configEventListener(MouseEvent.MOUSE_OVER, this.onUpgradeMouseOver);
            this._commonAdvanceBtn.configEventListener(MouseEvent.MOUSE_OUT, this.onUpgradeMouseOut);
            this._autoAdvanceBtn.configEventListener(MouseEvent.CLICK, this.onClickUpgrade);
            this._autoAdvanceBtn.configEventListener(MouseEvent.MOUSE_OVER, this.onUpgradeMouseOver);
            this._autoAdvanceBtn.configEventListener(MouseEvent.MOUSE_OUT, this.onUpgradeMouseOut);
            this._stopAdvanceBtn.configEventListener(MouseEvent.CLICK, this.onClickUpgrade);
            this._stopAdvanceBtn.configEventListener(MouseEvent.MOUSE_OVER, this.onUpgradeMouseOver);
            this._stopAdvanceBtn.configEventListener(MouseEvent.MOUSE_OUT, this.onUpgradeMouseOut);
            LoaderHelp.addResCallBack(ResFileConst.petInfo, this.onRecCompl);
            NetDispatcher.addCmdListener(ServerCommand.PetAdvanceBack, this.onPetAdvanceBack);
            NetDispatcher.addCmdListener(ServerCommand.BackpackAllDataGet, this.setRightInfo);
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.setRightInfo);
            this.updateActiveBtn();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            Dispatcher.removeEventListener(EventName.ShopBuyItemFail, this.shopBuyItemFail);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
            this._hasCkAutoBtn = false;
            SevenDayLoginUtil.removeArrow(this._commonAdvanceBtn);
            if (this._timeoutNum != 0)
            {
                clearTimeout(this._timeoutNum);
            }
            this._timeoutNum = 0;
            this._commonAdvanceBtn.name = "";
            LoaderHelp.removeResEvent(ResFileConst.petInfo, this.onRecCompl);
            NetDispatcher.removeCmdListener(ServerCommand.PetAdvanceBack, this.onPetAdvanceBack);
            NetDispatcher.removeCmdListener(ServerCommand.BackpackAllDataGet, this.setRightInfo);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsChange, this.setRightInfo);
            UIFactory.disposeSprite(this._promoteSp, true);
            this._promoteSp = null;
            this._vcAttributeName.length = 0;
            this._vcAttributeNameText.length = 0;
            this._vcAttributeValueText.length = 0;
            this._vcAttributeAddValueText.length = 0;
            this._upgradeArrowArr.length = 0;
            this._level = null;
            this._name = null;
            this._advanceInfo = null;
            this._myselfHurt = null;
            this._addRoleHutr = null;
            this._progressBar = null;
            this._consumeItem = null;
            this._propTip = null;
            this._propNum = null;
            this._propName = null;
            this._autoBuy = null;
            this._commonAdvanceBtn = null;
            this._autoAdvanceBtn = null;
            this._stopAdvanceBtn = null;
            this._currLevel = null;
            this._nextLevel = null;
            this._curBg = null;
            this._nextBg = null;
            this._arrow = null;
            this._fullLevel = null;
            if (this._servenActivitiesBtn)
            {
                this._servenActivitiesBtn.dispose(param1);
                this._servenActivitiesBtn = null;
            }
            super.disposeImpl(param1);
            return;
        }// end function

        private function updateActiveBtn() : void
        {
            if (Cache.instance.openServerSevenDay.getTargetTypeName() == "" + Language.getString(71763))
            {
                if (this._servenActivitiesBtn == null)
                {
                    this._servenActivitiesBtn = UIFactory.gLoadingButton(ResFileConst.sevenDayActiveBtn, 200, 424, 44, 44, this);
                }
                this._servenActivitiesBtn.configEventListener(MouseEvent.CLICK, this.openServenDayWin);
            }
            else if (this._servenActivitiesBtn)
            {
                this._servenActivitiesBtn.removeEventListener(MouseEvent.CLICK, this.openServenDayWin);
                this._servenActivitiesBtn.dispose();
                this._servenActivitiesBtn = null;
            }
            return;
        }// end function

        private function openServenDayWin(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RebateOpenServerSevenDayModule, null));
            return;
        }// end function

        protected function onClickUpgrade(event:MouseEvent) : void
        {
            var _loc_3:int = 0;
            var _loc_4:ItemData = null;
            var _loc_5:ItemInfo = null;
            var _loc_6:ItemData = null;
            var _loc_7:int = 0;
            var _loc_8:Dictionary = null;
            var _loc_9:int = 0;
            var _loc_10:Boolean = false;
            var _loc_11:Array = null;
            var _loc_12:Array = null;
            var _loc_13:int = 0;
            var _loc_14:int = 0;
            var _loc_15:int = 0;
            SevenDayLoginUtil.removeArrow(this._commonAdvanceBtn);
            if (this._pet == null)
            {
                return;
            }
            if (event.target == this._autoAdvanceBtn)
            {
                this._hasCkAutoBtn = true;
            }
            else if (event.target == this._stopAdvanceBtn)
            {
                this._hasCkAutoBtn = false;
            }
            var _loc_2:* = MountConfig.instance.getFashionInfoByCode(EAdvanceComponentType._EAdvanceComponentTypePet, this._pet.code);
            if (_loc_2)
            {
                _loc_3 = _loc_2.propNum;
                _loc_4 = new ItemData(int(_loc_2.propConsume));
                if (_loc_4 == null)
                {
                    MsgManager.showRollTipsMsg("itemData null 2");
                    return;
                }
                _loc_5 = ItemConfig.instance.getConfig(int(_loc_2.propConsume));
                _loc_6 = MountUtil.isHasBlessItem(_loc_5.type);
                if (_loc_6 == null)
                {
                    _loc_7 = this.propNum(_loc_4, true);
                }
                if (_loc_6 == null && _loc_7 < _loc_2.propNum && !this._autoBuy.selected && event.target != this._stopAdvanceBtn)
                {
                    if (GuideController.currentGuideItemWin == ModuleType.Pets)
                    {
                        MsgManager.showMouseMsg("" + Language.getString(71764), MsgRollTipsType.msgRollTips3);
                        this.stopAutoAdvance();
                        GameController.playerSystem.view.hide();
                        GuideController.currentGuideItemWin = null;
                    }
                    else
                    {
                        if (GiftsUtil.isCanUseFreeGift(_loc_5.group, _loc_5.category, _loc_5.type, int.MAX_VALUE, EGiftBag._EGiftBagFix))
                        {
                            MsgManager.showRollTipsMsg("" + Language.getString(71765));
                            this.stopAutoAdvance();
                            return;
                        }
                        if (BuyGiftItemWin.isAutoBuy)
                        {
                            BuyGiftItemWin.isNeedTobuyCurTime = true;
                            Dispatcher.addEventListener(EventName.ShopBuyItemFail, this.shopBuyItemFail);
                            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
                        }
                        else
                        {
                            MsgManager.showMouseMsg("" + Language.getString(71766), MsgRollTipsType.msgRollTips3);
                            this.stopAutoAdvance();
                        }
                        BuyGiftItemWin.instance.setBuyData(_loc_5.code, 2, _loc_2.propNum - _loc_7, this._window.x + this._window.width + 5, this._window.y - 3);
                    }
                }
                else
                {
                    if (_loc_5 == null)
                    {
                        MsgManager.showRollTipsMsg("itemInfo null 3");
                        return;
                    }
                    _loc_8 = new Dictionary();
                    if (_loc_6)
                    {
                        _loc_8[_loc_6.serverData.uid] = 1;
                    }
                    else
                    {
                        _loc_9 = ShopConfig.instance.getFastBuyItemByCode(_loc_5.bind ? (_loc_5.codeUnbind) : (_loc_5.code)).prize * _loc_2.propNum;
                        _loc_10 = Cache.instance.role.enoughMoney(EPriceUnit._EPriceUnitGoldBind, _loc_9, null, false);
                        if (this._autoBuy.selected && _loc_7 < _loc_2.propNum && !_loc_10 && GiftsUtil.isCanUseGift(_loc_4.itemInfo.group, _loc_4.itemInfo.category, _loc_4.itemInfo.type, _loc_2.code) && event.target == this._autoAdvanceBtn)
                        {
                            this.stopAutoAdvance();
                            return;
                        }
                        _loc_11 = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(_loc_4.itemInfo.group, _loc_4.itemInfo.category, _loc_4.itemInfo.type);
                        if (_loc_11 == null)
                        {
                            MsgManager.showRollTipsMsg("arr null 4");
                            return;
                        }
                        _loc_12 = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(EGroup._EGroupStuff, EStuff._EStuffAdvance, EAdvanceType._EAdvanceTypeAllRoundUp);
                        _loc_11 = _loc_11.concat(_loc_12);
                        _loc_11.sort(this.sortItem);
                        _loc_14 = _loc_11.length;
                        while (_loc_15 < _loc_14)
                        {
                            
                            if (ItemsUtil.isPrescriOutTime(_loc_11[_loc_15] as ItemData))
                            {
                            }
                            else if (this._pet.code >= (_loc_11[_loc_15] as ItemData).itemInfo.effect)
                            {
                                _loc_13 = _loc_13 + (_loc_11[_loc_15] as ItemData).itemAmount;
                                _loc_8[(_loc_11[_loc_15] as ItemData).uid] = (_loc_11[_loc_15] as ItemData).itemAmount;
                                if (_loc_13 >= _loc_3)
                                {
                                    _loc_8[(_loc_11[_loc_15] as ItemData).uid] = (_loc_11[_loc_15] as ItemData).itemAmount - _loc_13 + _loc_3;
                                    break;
                                }
                            }
                            _loc_15++;
                        }
                    }
                    if (event.target == this._autoAdvanceBtn)
                    {
                        this._isAutoingRefresh = true;
                    }
                    else if (event.target == this._stopAdvanceBtn)
                    {
                        this.stopAutoAdvance();
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetAdvance, {autoBuy:this._autoBuy.selected, items:_loc_8}));
                }
            }
            return;
        }// end function

        private function keepLevelUp(param1:Array) : void
        {
            var _loc_2:* = param1[0] as ItemData;
            if (ItemsUtil.isPetAdvanced(_loc_2))
            {
                Dispatcher.removeEventListener(EventName.ShopBuyItemFail, this.shopBuyItemFail);
                NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
                if (this._hasCkAutoBtn && BuyGiftItemWin.isAutoBuy)
                {
                    this._isAutoingRefresh = true;
                    this._autoAdvanceBtn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
                }
                else
                {
                    this._hasCkAutoBtn = false;
                    this._commonAdvanceBtn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
                }
            }
            return;
        }// end function

        private function shopBuyItemFail(event:DataEvent) : void
        {
            this.stopAutoAdvance();
            this._hasCkAutoBtn = false;
            return;
        }// end function

        public function sortItem(param1:ItemData, param2:ItemData) : int
        {
            if (!ItemsUtil.isPrescriptionItem(param1) && ItemsUtil.isPrescriptionItem(param2))
            {
                return 1;
            }
            if (ItemsUtil.isPrescriptionItem(param1) && !ItemsUtil.isPrescriptionItem(param2))
            {
                return -1;
            }
            if (param1.itemInfo.effect > param2.itemInfo.effect)
            {
                return -1;
            }
            if (param1.itemInfo.effect < param2.itemInfo.effect)
            {
                return 1;
            }
            if (param1.bind == EBind._EBindYes && param2.bind == EBind._EBindNo)
            {
                return -1;
            }
            if (param1.bind == EBind._EBindNo && param2.bind == EBind._EBindYes)
            {
                return 1;
            }
            if (ItemsUtil.isAllRoundUpStone(param1) && !ItemsUtil.isAllRoundUpStone(param2))
            {
                return 1;
            }
            if (!ItemsUtil.isAllRoundUpStone(param1) && ItemsUtil.isAllRoundUpStone(param2))
            {
                return -1;
            }
            return 0;
        }// end function

        private function propNum(param1:ItemData, param2:Boolean) : int
        {
            var _loc_4:Array = null;
            var _loc_6:int = 0;
            var _loc_8:int = 0;
            var _loc_3:* = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(param1.itemInfo.group, param1.itemInfo.category, param1.itemInfo.type);
            if (param2)
            {
                _loc_4 = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(EGroup._EGroupStuff, EStuff._EStuffAdvance, EAdvanceType._EAdvanceTypeAllRoundUp);
                _loc_3 = _loc_3.concat(_loc_4);
            }
            var _loc_5:* = Cache.instance.newPet.pet;
            if (_loc_5 == null)
            {
                return 0;
            }
            var _loc_7:* = _loc_3.length;
            while (_loc_8 < _loc_7)
            {
                
                if (ItemsUtil.isPrescriOutTime(_loc_3[_loc_8] as ItemData))
                {
                }
                else if (_loc_5.code >= (_loc_3[_loc_8] as ItemData).itemInfo.effect)
                {
                    _loc_6 = _loc_6 + (_loc_3[_loc_8] as ItemData).itemAmount;
                }
                _loc_8++;
            }
            return _loc_6;
        }// end function

        private function getAdvanceItem(param1:int) : int
        {
            var _loc_2:int = 0;
            var _loc_6:int = 0;
            var _loc_3:* = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(EGroup._EGroupStuff, EStuff._EStuffAdvance, param1);
            var _loc_4:* = _loc_3.length;
            var _loc_5:* = Cache.instance.newPet.pet;
            if (_loc_5 == null)
            {
                return 0;
            }
            while (_loc_6 < _loc_4)
            {
                
                if (ItemsUtil.isPrescriOutTime(_loc_3[_loc_6] as ItemData))
                {
                }
                else if (_loc_5.code >= (_loc_3[_loc_6] as ItemData).itemInfo.effect)
                {
                    _loc_2 = _loc_2 + (_loc_3[_loc_6] as ItemData).itemAmount;
                }
                _loc_6++;
            }
            return _loc_2;
        }// end function

        private function callLater() : void
        {
            if (this._timeoutNum > 0)
            {
                this.starAutoAdvance();
                clearTimeout(this._timeoutNum);
            }
            this._timeoutNum = 0;
            return;
        }// end function

        private function onPetAdvanceBack(param1:Object) : void
        {
            if (param1 && this._isAutoingRefresh)
            {
                this._timeoutNum = setTimeout(this.callLater, 300);
            }
            else if (Boolean(param1) == false)
            {
                this.stopAutoAdvance();
            }
            return;
        }// end function

        private function stopAutoAdvance() : void
        {
            if (this._timeoutNum > 0)
            {
                clearTimeout(this._timeoutNum);
            }
            this._timeoutNum = 0;
            this._isAutoingRefresh = false;
            this._autoAdvanceBtn.visible = true;
            this._stopAdvanceBtn.visible = false;
            Dispatcher.removeEventListener(EventName.ShopBuyItemFail, this.shopBuyItemFail);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
            return;
        }// end function

        private function starAutoAdvance() : void
        {
            this._autoAdvanceBtn.visible = false;
            this._stopAdvanceBtn.visible = true;
            this._autoAdvanceBtn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
            return;
        }// end function

        private function onUpgradeMouseOver(event:MouseEvent) : void
        {
            this._overFun.call();
            this._promoteSp.visible = true;
            return;
        }// end function

        private function onUpgradeMouseOut(event:MouseEvent) : void
        {
            this._outFun.call();
            this._promoteSp.visible = false;
            return;
        }// end function

        private function setRightInfo(param1:Object = null) : void
        {
            var _loc_2:ItemData = null;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_9:int = 0;
            if (this._pet == null)
            {
                return;
            }
            var _loc_3:* = MountConfig.instance.getFashionInfoByCode(EAdvanceComponentType._EAdvanceComponentTypePet, this._pet.code);
            var _loc_4:* = MountConfig.instance.getFashionInfoByCode(EAdvanceComponentType._EAdvanceComponentTypePet, (this._pet.code + 1));
            this._consumeItem.filters = null;
            if (_loc_4)
            {
                this._commonAdvanceBtn.enabled = true;
                this._autoAdvanceBtn.enabled = true;
                this._advanceInfo.text = _loc_3.code + Language.getStringByParam(71767, _loc_4.code);
                this._advanceInfo.visible = false;
                this._advanceInfo.y = 371;
                this._currLevel.text = "" + _loc_3.code;
                this._nextLevel.text = "" + _loc_4.code;
                var _loc_10:Boolean = true;
                this._nextLevel.visible = true;
                this._currLevel.visible = _loc_10;
            }
            else
            {
                this.setFull(true);
                this._commonAdvanceBtn.enabled = false;
                this._autoAdvanceBtn.enabled = false;
                this._advanceInfo.text = "";
                this._advanceInfo.visible = true;
                this._advanceInfo.y = 366;
                var _loc_10:Boolean = false;
                this._nextLevel.visible = false;
                this._currLevel.visible = _loc_10;
            }
            var _loc_5:* = int(_loc_3.propConsume);
            _loc_2 = new ItemData(int(_loc_5));
            var _loc_6:* = MountUtil.isHasBlessItem(_loc_2.itemInfo.type);
            if (_loc_6)
            {
                this._consumeItem.itemData = _loc_6;
                this._consumeItem.amount = _loc_6.serverData.itemAmount;
                this._propNum.text = "*" + 1;
                this._propName.htmlText = ItemsUtil.getItemName(this._consumeItem.itemData, "[{0}]");
                this._consumeItem.bitmapEnable = true;
            }
            else
            {
                _loc_7 = this.getAdvanceItem(EAdvanceType._EAdvanceTypeAllRoundUp);
                _loc_8 = this.propNum(_loc_2, true);
                if (_loc_8 != 0 && _loc_8 == _loc_7 && _loc_8 >= _loc_3.propNum)
                {
                    _loc_5 = this._roundArrCode;
                }
                _loc_2 = new ItemData(int(_loc_5));
                _loc_2.itemAmount = _loc_8;
                this._consumeItem.itemData = _loc_2;
                this._propNum.text = "*" + _loc_3.propNum;
                if (_loc_5 == this._roundArrCode)
                {
                    this._propName.htmlText = HTMLUtil.addColor("[" + this._consumeItem.itemData.itemInfo.htmlName + "]", "#FF7902");
                }
                else
                {
                    this._propName.htmlText = "[" + this._consumeItem.itemData.itemInfo.htmlName + "]";
                }
                if (_loc_8 < _loc_3.propNum)
                {
                    this._consumeItem.bitmapEnable = false;
                    this._consumeItem.setAmountLabel(HTMLUtil.addColor("" + _loc_8, "#ff0000"));
                }
                else
                {
                    this._consumeItem.bitmapEnable = true;
                }
            }
            this._progressBar.setValue(this._pet.bless, _loc_3.blessMax);
            this._myselfHurt.text = _loc_3.petDamage.toString();
            if (param1)
            {
                _loc_9 = PetUtil.petCombat(_loc_3);
                this._addRoleHutr.text = _loc_9.toString();
                this._level.imgUrl = this.getPetUrl(this._pet.code);
                this._name.text = _loc_3.name;
                this.setAttr(_loc_3, _loc_4);
            }
            return;
        }// end function

        private function setFull(param1:Boolean) : void
        {
            this._fullLevel.visible = param1;
            this._currLevel.visible = !param1;
            this._curBg.visible = !param1;
            this._nextBg.visible = !param1;
            this._nextLevel.visible = !param1;
            this._arrow.visible = !param1;
            this._commonAdvanceBtn.enabled = !param1;
            this._autoAdvanceBtn.enabled = !param1;
            this._stopAdvanceBtn.enabled = !param1;
            if (param1)
            {
                this._commonAdvanceBtn.filters = [FilterConst.colorFilter2];
                this._autoAdvanceBtn.filters = [FilterConst.colorFilter2];
                this._stopAdvanceBtn.filters = [FilterConst.colorFilter2];
            }
            else
            {
                this._commonAdvanceBtn.filters = null;
                this._autoAdvanceBtn.filters = null;
                this._stopAdvanceBtn.filters = null;
            }
            return;
        }// end function

        public function updateName(param1:int) : void
        {
            var _loc_2:* = MountConfig.instance.getFashionInfoByCode(EAdvanceComponentType._EAdvanceComponentTypePet, this._pet.code);
            this._level.imgUrl = this.getPetUrl(this._pet.code);
            this._name.text = _loc_2.name;
            return;
        }// end function

        private function getPetUrl(param1:int) : String
        {
            return "levelIcon_" + param1 + ".png";
        }// end function

        private function setAttr(param1:TMountConfig, param2:TMountConfig) : void
        {
            var _loc_3:String = null;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_4:* = this._vcAttributeName.length;
            var _loc_5:int = 0;
            while (_loc_5 < _loc_4)
            {
                
                _loc_3 = this._vcAttributeName[_loc_5];
                _loc_7 = param1 ? (param1[_loc_3]) : (0);
                this._vcAttributeValueText[_loc_5].text = "" + PetUtil.petAttrByName(_loc_3, param1);
                if (this._pet.code < 10)
                {
                    _loc_8 = param2[_loc_3] - _loc_7;
                    if (_loc_8 <= 0)
                    {
                    }
                    this._vcAttributeAddValueText[_loc_5].text = _loc_8.toString();
                    this._vcAttributeAddValueText[_loc_5].visible = true;
                    this._upgradeArrowArr[_loc_5].visible = true;
                }
                else
                {
                    this._vcAttributeAddValueText[_loc_5].visible = false;
                    this._upgradeArrowArr[_loc_5].visible = false;
                }
                _loc_5++;
            }
            var _loc_6:* = PetUtil.nextPetAddCombat;
            this._addCombat.text = _loc_6 > 0 ? (_loc_6.toString()) : ("");
            this._addCombatIcon.visible = _loc_6 > 0 ? (true) : (false);
            return;
        }// end function

        public function setOverAndOutFun(param1:Function, param2:Function) : void
        {
            this._overFun = param1;
            this._outFun = param2;
            return;
        }// end function

        public function updateMsg(param1:SPublicPet2) : void
        {
            this._pet = param1;
            this.setRightInfo(true);
            return;
        }// end function

        private function getPetBlessToolTip() : ToolTipInfo
        {
            var _loc_2:BlessData = null;
            var _loc_1:* = Cache.instance.newPet.pet;
            if (_loc_1)
            {
                _loc_2 = new BlessData();
                _loc_2.bless = _loc_1.bless;
                _loc_2.blessClear = Cache.instance.newPet.petConfig.blessClear;
                _loc_2.leftSeconds = (_loc_1.blessExpiredDt.time - ClockManager.instance.nowDate.time) * 0.001;
                _loc_2.type = "" + Language.getString(71763);
                return new ToolTipInfo(TooltipType.Bless, _loc_2);
            }
            return null;
        }// end function

        public function showBtnFilter() : void
        {
            var _loc_2:Boolean = false;
            var _loc_3:int = 0;
            var _loc_6:int = 0;
            var _loc_1:* = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(EGroup._EGroupStuff, EStuff._EStuffAdvance, EAdvanceType._EAdvanceTypePetGrowth);
            var _loc_4:* = Cache.instance.newPet.petConfig.propNum;
            var _loc_5:* = _loc_1.length;
            while (_loc_6 < _loc_5)
            {
                
                if (ItemsUtil.isPrescriOutTime(_loc_1[_loc_6] as ItemData))
                {
                }
                else if (Cache.instance.newPet.pet.code >= (_loc_1[_loc_6] as ItemData).itemInfo.effect)
                {
                    _loc_3 = _loc_3 + (_loc_1[_loc_6] as ItemData).itemAmount;
                }
                _loc_6++;
            }
            if (_loc_3 >= _loc_4)
            {
                SevenDayLoginUtil.genGiftArrow(this._commonAdvanceBtn, -10, 12, 2, this._commonAdvanceBtn.parent);
            }
            else
            {
                SevenDayLoginUtil.removeArrow(this._commonAdvanceBtn);
            }
            return;
        }// end function

    }
}
